$(document).ready(function() {

  //获取留言列表

  function talkList() {
    var nid = $(".swiper-wrapper .swiper-slide:first-child").attr('value');
    $.ajax({
      type: "POST",
      url: "plugin.php?id=annual:verify",
      data: {
        action: 'newlist',
        nid: nid,
      },
      dataType: "json",
      async: false,
      success: function(data) {
        if (data.news != "") {
          $(".text-1 e").html(data.num);
          newAdd(data);
        }
      }
    });
  }

  /*留言客户端*/

  function newAdd(data) {
    console.log(data.news.length);
    var newall = data.news;
    for (var i = 0; i < newall.length; i++) {
      var str = "<div class='swiper-slide' value=" + newall[i]['id'] + ">";
      str += "<img class='header-pic' src='uc_server/avatar.php?uid=" + newall[i]['uid'] + "'>";
      str += "<div class='text'><h3><span>" + newall[i]['name'] + "</span>";
	  str +="<span><img src='source/plugin/annual/template/img/time.png' >"+ newall[i]['talk_date']+"</span></h3>";
      str += "<h4>" + newall[i]['new'] + "</h4></div>";
      str += "</div>";
      $('.swiper-wrapper').prepend(str);
    }   
  }
  //定时刷新页面数据
  setInterval(talkList, 3000);
});